package models;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import play.db.jpa.Model;

@SuppressWarnings("serial")
@Entity
@Table(name = "borrow")
public class Borrow extends Model {

/*	名称 
	 代码 
	订单详情表ID   bor_id 
	订单信息表ID   ind_id 
	借阅数量   bor_amo 
	借阅时间   bor_time 
	正常归还时间   bor_sbt 
	实际归还时间   bor_rbt 
	借阅书籍状态   bor_sta 
	书籍id   boo_id */
	 

	@ManyToOne(fetch = FetchType.LAZY)
	public Indent indent; 
	
	@Column(name="bor_amo")
	public Integer boramo; 
	
	@Column(name="bor_time")
	public Date bortime; 
	
	@Column(name="bor_sbt")
	public Date borsbt; 
	
	@Column(name="bor_rbt")
	public Date borrbt; 
	
	@Column(name="bor_sta")
	public Integer borsta; 
	
	@Column(name="boo_id",length=50)
	public String booid; 
	
	@Transient
	private Book boo;

	public Book getBoo() {
		try{
			this.boo = Book.findById(Long.parseLong(booid));
			return this.boo;
		}catch(Exception e){
			return null;
		}
	}

	public void setBoo(Book boo) {
		this.boo = boo;
	}
}
